package org.projetjava.presentation;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Cursor;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import javax.imageio.ImageIO;
import javax.swing.BorderFactory;
import javax.swing.Box;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextArea;
import javax.swing.JTextField;

import org.projetjava.metier.model.HyperText;
import org.projetjava.metier.model.News;

public class AffichageNews extends JPanel {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	private JPanel panel;
	Box contNews;
	public Box getContNews() {
		return contNews;
	}

	public void setContNews(Box contNews) {
		this.contNews = contNews;
	}

	public Box getContNews2() {
		return contNews2;
	}

	public void setContNews2(Box contNews2) {
		this.contNews2 = contNews2;
	}

	public Box getContGeneral() {
		return contGeneral;
	}

	public void setContGeneral(Box contGeneral) {
		this.contGeneral = contGeneral;
	}

	Box contNews2;
	Box contGeneral;
	Box contGeneral2;


	public AffichageNews()
	{
		//this.setSize(1000,1000);
		
		panel = new JPanel();
		panel.setBounds(this.getWidth()/2 -225, this.getHeight()/2-150, 450, 300);
		
		panel.setMinimumSize(new Dimension(500, 500));
		panel.setPreferredSize(new Dimension(500, 500));
		panel.setMaximumSize(new Dimension(500, 500));
		
		panel.setLayout(new BorderLayout());
		contNews = Box.createHorizontalBox();
		contNews2 = Box.createHorizontalBox();
		contGeneral = Box.createVerticalBox();
		contGeneral2 = Box.createVerticalBox();
		
		contGeneral.setMinimumSize(new Dimension(200, 200));
		contGeneral.setPreferredSize(new Dimension(400, 400));
		contGeneral.setMaximumSize(new Dimension(400, 400));
		
		contGeneral2.setMinimumSize(new Dimension(200, 200));
		contGeneral2.setPreferredSize(new Dimension(400, 400));
		contGeneral2.setMaximumSize(new Dimension(200, 200));
		
		contNews.setMinimumSize(new Dimension(460, 100));
		contNews.setPreferredSize(new Dimension(460, 100));
		contNews.setMaximumSize(new Dimension(460, 100));
		
		contNews2.setMinimumSize(new Dimension(460, 100));
		contNews2.setPreferredSize(new Dimension(460, 100));
		contNews2.setMaximumSize(new Dimension(460, 100));
		
		//contGeneral2.add(Box.createVerticalGlue());
		contGeneral2.add(contGeneral);
		//contGeneral2.add(Box.createVerticalGlue());
		ImageDeFond pan = new ImageDeFond();
		
	
		//contGeneral.setBackground(Color.BLUE);
		//panel.setBackground(Color.LIGHT_GRAY);
		
		pan.setMinimumSize(new Dimension(300, 300));
		pan.setPreferredSize(new Dimension(300, 300));
		pan.setMaximumSize(new Dimension(300, 300));
		
		contGeneral.setBorder(BorderFactory.createRaisedBevelBorder());
		
		panel.add(contGeneral, BorderLayout.CENTER);
		
		this.add(panel);
		
		//this.add(pan, BorderLayout.WEST);

		
	}
	
	private void addListener(JLabel lb_url, String lien) {
		
        lb_url.addMouseListener(new ExecutionLienHyperText(lien));
    } 
	
	public void paintComponent(Graphics g)
	{
		panel.setBounds(this.getWidth()/2 -225, this.getHeight()/2-150, 450, 300);
		try {
		      Image img = ImageIO.read(new File("images/carte.png"));
		      g.drawImage(img, 0, 0, this.getWidth(), this.getHeight(), this);
		      //Pour une image de fond
		      //g.drawImage(img, 0, 0, this.getWidth(), this.getHeight(), this);
		    } catch (IOException e) {
		      e.printStackTrace();
		    }   
	}
}
